package org.techism.server;

import java.util.List;
import java.util.Map;
import java.util.SortedMap;
import java.util.logging.Logger;

import org.techism.client.bo.Group;
import org.techism.client.services.GroupService;
import org.techism.server.dao.GroupDao;
import org.techism.server.dao.impl.GroupDaoImpl;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;

public class GroupServiceImpl extends RemoteServiceServlet implements GroupService {

	private static final Logger log = Logger.getLogger(GroupServiceImpl.class.getName());

	private static final long serialVersionUID = 3435374626932903620L;

	private static GroupDao groupDao = new GroupDaoImpl();

	@Override
	public List<Group> getAllGroups() {
		return groupDao.findAllGroups();
	}

	@Override
	public List<Group> getByTag(final String tag) {
		if (tag == null) {
			return getAllGroups();
		} else {
			return groupDao.findGroupsByTag(tag);
		}
	}

	@Override
	public SortedMap<String, Integer> getTags() {
		return groupDao.findAllTags();
	}
}
